import 'dart:convert';

import 'package:http/http.dart' as http;

class NetworkHelper {
  final String url;

  NetworkHelper({required this.url});

  Future<dynamic> getData() async {
    Uri uri = Uri.parse(url);
    http.Response response = await http.get(uri);
    if (response.statusCode == 200) {
      String body = response.body;
      print('天气数据：$body');
      return jsonDecode(body);
    } else {
      print('响应码：${response.statusCode}');
    }
  }
}
